<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateRiskOrderTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('risk_order', function (Blueprint $table) {
            $table->bigIncrements('id');

            $table->integer('orderid')->nullable()->comment('订单ID');
            $table->string('ordersn',40)->nullable()->comment('订单号');
            $table->string('mobile',20)->nullable()->comment('手机号');
            $table->string('id_name',20)->nullable()->comment('身份证姓名');
            $table->string('id_card',20)->nullable()->comment('身份证');
            $table->string('openid',50)->nullable()->comment('openid');
            $table->decimal('money',12,2)->default(0)->comment('金额');
            $table->integer('dengji')->nullable()->default(0)->comment('等级');
            $table->smallInteger('status')->nullable()->comment('状态');
            $table->integer('risk_rules_id')->nullable()->comment('命中风控ID');
            $table->string('sys',10)->nullable()->comment('三要素');
            $table->string('sjzwzt',10)->nullable()->comment('手机在网状态');
            $table->string('fyxxxqfjb',10)->nullable()->comment('信息验证规则-法院信息详情个人高级版');

            $table->string('jdyx')->nullable()->comment('借贷');

            $table->string('tsmd')->nullable()->comment('特殊名单');
            $table->string('fxsb')->nullable()->comment('风险哨兵');
            $table->string('gzmc')->nullable()->comment('规则名称');

            $table->text('data')->nullable()->comment('数据');


            $table->timestamps();
        });

        Schema::table('risk_rules', function (Blueprint $table) {
            $table->smallInteger('status')->default(0)->after('dengji')->comment('状态 0 启用 1不启用');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('risk_order');
        Schema::table('risk_rules', function (Blueprint $table) {
            $table->dropColumn('status');
        });

    }
}
